#include<bits/stdc++.h>

using namespace std;
int n, k, cn;
string s, bb[605];
bool f[605];
map<int, string> m;

int main() {
    cin >> n >> s >> k;
    m[0] = s;
    for (int i = 1; i <= k; i++) {
        int a, b, c;
        char d;
        string aa;
        scanf("%d", &a);
        if (a == 1) {
            cin >> b >> c >> d;
            aa = m[b];
            aa[c - 1] = d;
            m[i] = aa;
        } else {
            cin >> b >> c;
            aa = m[b];
            aa = aa.substr(0, c - 1) + aa.substr(c);
            m[i] = aa;
        }
        //cout<<k;
    }

    for (auto t: m) {
        bb[cn++] = t.second;
    }

    sort(bb + 1, bb + cn);


    for (auto t: m) {

        if (t.first != 0) {
            for (int i = 1; i < cn; i++) {
                if (bb[i] == t.second && !f[i]) {
                    cout << i << " ";
                    f[i] = true;
                    break;
                }
            }

        }
        //   cout<<t.second;
    }
    return 0;